/*
package com.daxt.webservice;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.daxt.base.common.util.RedisUtil;
import com.daxt.common.result.Result;
import com.daxt.mapper.archives.ArchivesAcceptDataMapper;
import com.daxt.mapper.archives.ArchivesAdministrationDocMapper;
import com.daxt.mapper.archives.ArchivesDocFileMapper;
import com.daxt.mapper.archives.ArchivesDocMapper;
import com.daxt.model.dic.SystemConfigType;
import com.daxt.model.service.archives.vo.*;
import com.daxt.service.MountService;
import com.daxt.utils.XmlDomUtil;
import com.daxt.utils.ZipUtil;
import com.daxt.utils.file.FileBaseUtil;
import com.daxt.utils.file.PdfUtils;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import net.lingala.zip4j.exception.ZipException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.io.File;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

*/
/**
 *  通过webService的方式对外提供接口
 *//*

@WebService
@Service
public class AcceptWebServiceImplNew implements  AcceptWebService {

    @Autowired
    private ArchivesAcceptDataMapper archivesAcceptDataMapper;

    @Autowired
    private ArchivesDocMapper archivesDocMapper;

    @Autowired
    private ArchivesDocFileMapper archivesDocFileMapper;

    @Autowired
    private ArchivesAdministrationDocMapper administrationDocMapper;

    @Autowired
    private MountService mountService;

    */
/**
     * 用于政务服务行政审批系统预归档到电子文件归档处理系统，在线接收归档格式包
     *//*

    @WebMethod(operationName = "dateAccept")
    @Override
    public String dateAccept(@WebParam(name = "jsonData") String jsonData) {

        Map<String,String> result=new HashMap<String,String>();
        boolean isjson= isJson(jsonData);

        if(!isjson){
            result.put("resultCode", "2");
            result.put("resultMsg", "接受失败，不是json格式");
            return JSON.toJSONString(result);
        }
        ArchivesAcceptData archivesAccept=JSON.parseObject(jsonData,ArchivesAcceptData.class);

        //判断各个参数是否为空
        if(StringUtils.isEmpty(archivesAccept.getDataName())){
            result.put("resultCode", "2");
			result.put("resultMsg", "电子文件名称不能为空");
			return JSON.toJSONString(result);
        }else if(StringUtils.isEmpty(archivesAccept.getDataPath())){
            result.put("resultCode", "2");
            result.put("resultMsg", "数据包的存放路径不能为空");
            return JSON.toJSONString(result);
        }else if(StringUtils.isEmpty(archivesAccept.getAreaCode())){
            result.put("resultCode", "2");
            result.put("resultMsg", "区域码不能为空");
            return JSON.toJSONString(result);
        }else if(StringUtils.isEmpty(archivesAccept.getDeptCode())){
            result.put("resultCode", "2");
            result.put("resultMsg", "部门编码不能为空");
            return JSON.toJSONString(result);
        }else if(StringUtils.isEmpty(archivesAccept.getArg())){
            result.put("resultCode", "2");
            result.put("resultMsg", "系统编码不能为空");
            return JSON.toJSONString(result);
        }

        //保存数据
        archivesAccept.setCreateTime(LocalDateTime.now());
        archivesAccept.setUpdateTime(LocalDateTime.now());
        Integer row=archivesAcceptDataMapper.insert(archivesAccept);

        if(row<=0){
            result.put("resultCode", "2");
            result.put("resultMsg", "接受失败");
            return JSON.toJSONString(result);
        }

        //返回响应结果
        result.put("resultCode", "1");
        result.put("resultMsg", "接受成功");
        return JSON.toJSONString(result);
    }


    */
/*@WebMethod
    public String datafeedback(@WebParam(name="dataName") String dataName,@WebParam(name="detectionCode") String detectionCode,
        @WebParam(name="detectionMsg") String detectionMsg) {

        QueryWrapper<ArchivesAcceptData> queryWrapper=new QueryWrapper();
        queryWrapper.eq("dataName",dataName);
        queryWrapper.select(" dataPath ");
        ArchivesAcceptData archivesAcceptData = archivesAcceptDataMapper.selectOne(queryWrapper);

        Map<String,String> result=new HashMap<String,String>();

        //若文件不存在，则直接退出
        if(archivesAcceptData==null){
            result.put("resultCode","2");
            result.put("resultMsg","解析失败:文件不存在");
            return JSON.toJSONString(result);
        }

        //FileBaseUtil.getFileDirName();

        try {

            File zipfile=new File(archivesAcceptData.getDataPath());

            System.out.println();
            if(zipfile.exists()){
                //获取zip文件后缀
                String ext= FileBaseUtil.getFileExtName(zipfile);
                System.out.println("ext:"+ext);
                if(!"zip".equals(ext)){
                    result.put("resultCode","2");
                    result.put("resultMsg","解析失败:压缩文件不合法");
                    return JSON.toJSONString(result);
                }

                String[] zipFileNames = FileBaseUtil.getFileDirName(zipfile).split("-");
                String depName=zipFileNames[0];             //33000019 部门为浙江省建设厅
                String authorityType=zipFileNames[1];       //01       权力事项类型为行政许可事项
                String authorityBigCode=zipFileNames[2];    //00190    权力事项大类代码为00190
                String authorityLittleCode=zipFileNames[3]; //001      权力事项小类代码为001
                String endYear=zipFileNames[4];             //2017     办结年份为2017年
                String retentionperiod=zipFileNames[5];     //5年      保管期限为5年
                String informationPackage=zipFileNames[6];  //0000006  第6个存档信息包


                //获取文件解压路径
                String  zipPath= FileBaseUtil.getFileNameFront(archivesAcceptData.getDataPath());

                //解压zip文件包
                File[] files= ZipUtil.unzip(zipfile,zipPath,null);

                //判断文件是否成功解析
                boolean isisArchives= XmlDomUtil.isArchives(zipPath);
                if(isisArchives==false){
                    //result.put("resultCode","2");
                    //result.put("resultMsg","接受失败，文件未能成功解析");
                    //return JSON.toJSONString(result);
                }

                //获取解压后所有的jpd文件
                List<String> xmlFiles= XmlDomUtil.getXmlFiles(zipPath,"jpg");
                //将所有图片合成为pdf文件
                PdfUtils.imgToPdf(xmlFiles,"F:\\zjq\\zjq.pdf");


                //解析基础信息表
                ArchivesAdministrationDoc  administrationDoc=XmlDomUtil.getArchivesDocXml(zipPath);

                ArchivesDoc archivesDoc=new ArchivesDoc();
                archivesDoc.setStartTime(administrationDoc.getReceiveTime());
                archivesDoc.setDutyPeople(administrationDoc.getLegalman());
                archivesDoc.setDutyCompany(administrationDoc.getReceiveDepartmentName());
                archivesDoc.setArchivingTime(administrationDoc.getArchiveTime());
                archivesDoc.setTitle(administrationDoc.getProjectName());
                archivesDoc.setEndTime(administrationDoc.getTransactTime());
                archivesDoc.setStoragePeriod(administrationDoc.getRetentionPeriod());
                archivesDoc.setState("6");
                archivesDoc.setCreateTime(LocalDateTime.now());
                archivesDoc.setFileType("doc");
                archivesDoc.setFondsId("13");

                administrationDoc.setCreateTime(LocalDateTime.now());
                //System.out.println(archivesDoc);
                //将基础信息存储在数据库中
                archivesDocMapper.insert(archivesDoc);
                administrationDoc.setDocId(archivesDoc.getId());
                administrationDocMapper.insert(administrationDoc);

                //-----------------------------------------------
                String get32uuid = IdWorker.get32UUID();
                String ossDir = RedisUtil.getSysConfig(SystemConfigType.OSS_DIR);
                //外部接收目录
//              String directory = "D:/a/zipPage/";
                String directory = "administration/" + get32uuid + "/";

                //File baseInfoXml = new File(zipPath+ "\\基本信息描述.xml");

                System.out.println(ossDir+directory);
                System.out.println("ArchivesAdministrationDoc:" + administrationDoc);

                //处理附件
                //获取解压后所有的pdf文件
                List<String> pdfFiles= XmlDomUtil.getXmlFiles(zipPath,"pdf");

                //附件上传
                pdfFiles.forEach((String filePath) -> {

                    String fileName=FileBaseUtil.getPathFileName(filePath.replace("\\","/"));

                    FileBaseUtil.getPathFileName(filePath);
                    ArchivesDocFile archivesDocFile = new ArchivesDocFile();
                    archivesDocFile.setDocId(archivesDoc.getId());
                    archivesDocFile.setFileUrl(directory  +fileName);

                    archivesDocFile.setFileName(fileName.substring(0,fileName.lastIndexOf(".")-1));
                    archivesDocFile.setFileType("1");

                    archivesDocFile.setItemNum(archivesDoc.getItemNum());
                    archivesDocFile.setExtName(FileBaseUtil.getFileNameExt(filePath));
                    archivesDocFile.setCreateTime(LocalDateTime.now());

                    //将文件移动到目标地址
                    System.out.println("文件移动目标地址:"+ossDir+directory);
                    System.out.println("文件移动源地址:"+filePath);
                    FileBaseUtil.copy(filePath,ossDir+directory);

                    //accessory.setFileUrl(archivesDocFile.getFileUrl());
                    Result<String> mountFile = mountService.baseMountFile(archivesDocFile);
                    System.out.println("mountFile："+mountFile.getMsg());
                    System.out.println("mountFile："+mountFile.getData());
                    System.out.println("mountFile："+mountFile.getCode());

                    //System.out.println(archivesDocFile);
                });

                result.put("resultCode","1");
                result.put("resultMsg","接受成功");
            }else{
                result.put("resultCode","2");
                result.put("resultMsg","接受失败:文件不存在");
            }
        }catch (ZipException e){
            e.printStackTrace();
            result.put("resultCode","2");
            result.put("resultMsg","解析失败:压缩文件不合法,可能被损坏");
        }

        return JSON.toJSONString(result);
    }*//*




    */
/**
     * @description: 判断是否是一个json字符串
     *
     * @author: lig
     * @date: 2022/7/29
     *//*

    private boolean isJson(String str){
        try {
            JSONObject jsonStr= JSONObject.parseObject(str);
            return  true;
        } catch (Exception e) {
            return false;
        }

    }

}
*/
